package com.ruoyi.web.controller.monitor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.system.domain.vo.business.WcContentExamineSelectListDto;
import com.ruoyi.system.domain.vo.business.WcContentExamineSelectListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;

/**
 * 操作日志记录
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/monitor/operlog")
@Api(tags = "（操作日志记录")
public class SysOperlogController extends BaseController {
    @Autowired
    private ISysOperLogService operLogService;

    @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
    @GetMapping("/list")
    @ApiOperation(value = "操作记录列表", response = SysOperLog.class)
    public TableDataInfo list(SysOperLog operLog) {
        startPage();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }

    @ApiOperation("操作记录列表字段")
    //@RequiresPermissions("system:application:list")
    @PostMapping("/getList")
    @ResponseBody
    public AjaxResult<Page<SysOperLog>> getList(@RequestBody WcContentExamineSelectListDto dto) {
        return success();
    }

    //    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysOperLog operLog)
//    {
//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
//        util.exportExcel(response, list, "操作日志");
//    }


    //    @Log(title = "操作模块", businessType = BusinessType.EXPORT)
    @PostMapping("/titleType")
    @ApiOperation("操作模块 枚举字段")
    public AjaxResult<List> getTypeTitle() {
        HashMap map = new HashMap();
        List list=new  ArrayList();

        map.put("系统管理", "系统管理");
        map.put("专题管理", "专题管理");
        map.put("单位基本信息", "单位基本信息");
        map.put("公映许可证信息", "公映许可证信息");
        map.put("剧本变更备案申请", "剧本变更备案申请");
        map.put("剧本备案申请", "剧本备案申请");
        map.put("单位注册审批记录", "单位注册审批记录");
        map.put("菜单管理", "菜单管理");
        map.put("角色管理", "角色管理");
        map.put("用户管理", "用户管理");
        map.put("banner", "banner");
        list.add(map.get(0));
        list.add(map.get(1));
        list.add(map.get(2));
        list.add(map.get(3));
        list.add(map.get(4));
        list.add(map.get(5));
        list.add(map.get(6));
        list.add(map.get(7));
        list.add(map.get(8));
        list.add(map.get(9));
        list.add(map.get(10));
        return AjaxResult.success(list);
    }
    @PostMapping("/titleTypeList")
    @ApiOperation("操作模块 枚举字段(数组格式)")
    public AjaxResult<List> titleTypeList() {
        HashMap map = new HashMap();
        List list=new  ArrayList();

        map.put("系统管理", "系统管理");
        map.put("专题管理", "专题管理");
        map.put("单位基本信息", "单位基本信息");
        map.put("公映许可证信息", "公映许可证信息");
        map.put("剧本变更备案申请", "剧本变更备案申请");
        map.put("剧本备案申请", "剧本备案申请");
        map.put("单位注册审批记录", "单位注册审批记录");
        map.put("菜单管理", "菜单管理");
        map.put("角色管理", "角色管理");
        map.put("用户管理", "用户管理");
        map.put("banner", "banner");
        list.add(map.get("系统管理"));
        list.add(map.get("专题管理"));
        list.add(map.get("单位基本信息"));
        list.add(map.get("公映许可证信息"));
        list.add(map.get("剧本变更备案申请"));
        list.add(map.get("剧本备案申请"));
        list.add(map.get("单位注册审批记录"));
        list.add(map.get("菜单管理"));
        list.add(map.get("角色管理"));
        list.add(map.get("用户管理"));
        list.add(map.get("banner"));
        return AjaxResult.success(list);
    }


    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
    @DeleteMapping("/{operIds}")
    public AjaxResult remove(@PathVariable Long[] operIds) {
        return toAjax(operLogService.deleteOperLogByIds(operIds));
    }

    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
    @DeleteMapping("/clean")
    public AjaxResult clean() {
        operLogService.cleanOperLog();
        return success();
    }
}
